package com.byxy.ssm.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.byxy.ssm.pojo.Forum;

public interface ForumMapper {
	@Delete("delete from forum where forum_id=#{forumId}")
    int delete(Integer forumId);
	
	
	@Insert("insert into forum(forum_name) values(#{forumName})") 
    int insert(Forum forum);
	

    @Select("select * from forum where forum_id=#{forumId}")
    @Results(id="dataset",value={
    	@Result(id=true,column="forum_id",property="forumId"),
    	@Result(column="forum_name",property="forumName"),
    })
    Forum getById(Integer forumId);
    
    
    @ResultMap("dataset")
    @Select("select * from forum")
    List<Forum> findAll();
    
    
    @Update("update forum set forum_name=#{forumName} where forum_id=#{forumId}")
    int update(Forum forum);
}